#include <stdlib.h>
#include <stdio.h>
#include <nds.h>

#include <string.h>

// common headers
#include "common.h"

// local headers

#include "librarylist.h"

int LL_addLib(LLIST **list, sLibrary *lib) {    // add a library to the list
    if(!list || !lib) return 1;

    return !ll_append_el(list, lib);    // returns 0 on success
}

void LL_removeLib(LLIST **list, sLibrary *lib) {
    if(!list || !*list || !lib) return;

    LLIST *el=ll_search_data(*list, (void *)lib);
    if(el) {
        if(!el->prev && !el->next) *list=NULL;

        ll_free_el(el);
    }
}

void LL_removeAll(LLIST **list) {
    if(!list) return;

    ll_free_all(*list);

    *list=NULL;
}

